package com.shundr.common;

import java.net.URL;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.shundr.R;
import com.shundr.base.BaseActivity;
import com.shundr.common.util.ToastHelper;
import com.shundr.common.view.ZoomImageView;

/**
 * 图片预览
 * PreviewActivity
 * 
 * @author larry 2015-5-16 下午4:55:49 
 * @version 1.0.0
 *
 */
public class PreviewActivity extends BaseActivity {

	private ImageLoader mImageLoader;

	private String mUrl = "";

	private ZoomImageView imgv;

	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		try {
			setContentView(R.layout.activity_preview_image);
			mUrl = getIntent().getStringExtra("url");
			this.mImageLoader = ImageLoader.getInstance();
			imgv = (ZoomImageView) findViewById(R.id.iv_image);
//			URL url = new URL("http://h.hiphotos.baidu.com/image/pic/item/377adab44aed2e73146edc2d8501a18b87d6fa28.jpg");
			URL url = new URL(mUrl);
			Bitmap bitmap = BitmapFactory.decodeStream(url.openStream());
			if(bitmap == null){
				ToastHelper.toastLong(mContext, "该图片不存在或网络连接异常，请检查后重试");
			}else{
				imgv.setImage(bitmap); 	
			}
		} catch (Exception e) {
			e.printStackTrace();
			ToastHelper.toastLong(mContext, "该图片不存在或网络连接异常，请检查后重试");
		}
	}
}
